/*
 * Created on 14. des.. 2006
 * Created by Tomas
 */
package gui;

import java.util.LinkedList;
import java.util.List;

import javax.swing.event.TreeModelEvent;
import javax.swing.event.TreeModelListener;
import javax.swing.tree.TreeModel;

/**
 * 
 * Handles the listeners to events of a treemodel
 * 
 * @author Tomas
 *
 */
public abstract class AbstractTreeModel implements TreeModel {
	private List<TreeModelListener> listeners = new LinkedList<TreeModelListener>();

	public void addTreeModelListener(TreeModelListener l) {
		listeners.add(l);
	}

	public void removeTreeModelListener(TreeModelListener l) {
		listeners.remove(l);
	}
	
	public void fireTreeNodesChanged(TreeModelEvent e) {
		for (TreeModelListener l : listeners) {
			l.treeNodesChanged(e);
		}
	}
	
	public void fireTreeNodesInserted(TreeModelEvent e) {
		for (TreeModelListener l : listeners) {
			l.treeNodesInserted(e);
		}
	}
	
	public void fireTreeNodesRemoved(TreeModelEvent e) {
		for (TreeModelListener l : listeners) {
			l.treeNodesRemoved(e);
		}
		
	}
	
	public void fireTreeStructureChanged(TreeModelEvent e) {
		for (TreeModelListener l : listeners) {
			l.treeStructureChanged(e);
		}
	}
}
